package com.gm.camunda.controller;

import com.gm.camunda.entity.TaskEntity;
import com.gm.camunda.service.ProcessTaskService;
import com.gmadmin.common.ApiResponse;
import com.gmadmin.common.Inner;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * {@code @Author}: zhang liang
 * {@code @Date}: 2022/10/9 20:34
 * {@code @BelongsProject}: gm
 * {@code @BelongsPackage}: com.gm.camunda.controller
 * {@code @Description}: 流程任务
 */
@RestController
@RequestMapping("/processTask")
public class ProcessTaskController {

    private final ProcessTaskService processTaskService;

    public ProcessTaskController(ProcessTaskService processTaskService) {
        this.processTaskService = processTaskService;
    }

    @Inner
    @GetMapping("/queryUserToDo")
    public ApiResponse queryUserToDo(String userId) {
        List<TaskEntity> tasks = processTaskService.queryUserToDo(userId);
        return ApiResponse.ofSuccess(tasks);
    }


    @Inner
    @PostMapping("/taskPass")
    public ApiResponse taskPass(String taskId) {
        processTaskService.taskPass(taskId);
        return ApiResponse.ofSuccess();
    }
}
